



// 用户名非空且不包含空白字符
let username_reg = /^\S{1,20}$/
const isValidUsername = (username) => {
    return username_reg.test(username)
}

// 密码不少于8位，包含且仅包含数字及大小写字母
let password_reg = /^[0-9a-zA-Z]{8,20}$/
let digit = /[0-9]/
let lower = /[a-z]/
let upper = /[A-Z]/
const isValidPassword = (password) => {
    return password_reg.test(password) && digit.test(password) &&
        lower.test(password) && upper.test(password)
}

// 昵称非空且不能过长
let space_reg = /^\s*$/
const isValidNickname = (nickname) => {
    if (space_reg.test(nickname) || nickname.length > 30) {
        return false
    }
    return true
}

module.exports = {
    isValidUsername,
    isValidPassword,
    isValidNickname
}